<template>
    <view class="content">
        <!-- 积分 订单结算 -->
        <view class="bg"></view>
        <view class="top">
            <view class="down" @click="$gTo('/mine/pages/address/address')">
                <!-- <view class="u-flex-1 u-font-36 text-bold u-padding-bottom-10" v-if="!userAdd">
                    <text>暂无地址，去添加~~</text>
                </view> -->
                <view>
                    <view class="add-text">
                        <text class="add-icon">地址</text>
                        <text class="add">高新区硅谷大街与荷园路交汇安联国际B座10楼1043室</text>
                    </view>
                    <view class="u-flex">
                        <view class="add-name">张女士</view>
                        <view class="add-tel">13100001111</view>
                    </view>
                </view>
                <u-icon name="arrow-right" size="30" class="u-m-l-20"></u-icon>
            </view>
        </view>
        
        <view class="box u-p-t-30 u-p-b-30">
            <!-- <view class="item" v-for="(item, index) in data.goods" :key="index">
                <image :src="item.image_uri" class="del-07"></image>
                <view class="item-r">
                    <view class="goods-name u-line-2">{{item.goods_name}}</view>
                    <view class="u-flex u-p-t-40">
						<image src="../../static/icon/point_2.png" class="point-icon"></image>
                        <view class="price">{{item.point_price}}</view>
                    </view>
                </view>
            </view> -->
			
			<view class="item">
				<image src="../../static/del/5.png" class="del-07"></image>
			    <view class="item-r">
			        <view class="goods-name u-line-2">
						名称名称名称名称名称名称名称名称名称名称名称名称名称名称名称名称名称名称名称名称名称名称名称名称名称名称名称名称名称名称名称名称
					</view>
			        <view class="u-flex u-p-t-40">
						<image src="../../static/icon/point_2.png" class="point-icon"></image>
			            <view class="price">600</view>
			        </view>
			    </view>
			</view>
			<view class="freight">
				<view>运费</view>
				<view>包邮</view>
			</view>
            <view class="total">
                <view class="u-font-24 u-p-r-10">小计</view>
                <image src="../../static/icon/point_1.png" class="point-icon"></image>
                <view class="total-price-num">{{data.PointPrice}}</view>
            </view>
        </view>
        <view class="box u-p-t-30 u-p-b-30 u-flex u-row-between u-col-center">
            <view>备注</view>
            <view class="u-flex u-row-right u-flex-1" @click="$gTo('/pages/settlement/remarks?from=ZT')">
                <view class="remark">{{remark || '请添加备注'}}</view>
                <u-icon name="arrow-right" size="30"></u-icon>
            </view>
        </view>
        <!-- 底部 -->
        <view class="footer">
            <view class="u-flex">
                <view class="u-p-r-10">合计：</view>
                <image src="../../static/icon/point_2.png" class="point-icon"></image>
                <view class="footer-price-num">{{data.PointPrice}}</view>
            </view>
            <view class="footer-btn" @click="$noMultipleClicks(addOrder)">立即兑换</view>
        </view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                noClick:true,//连点
                data: {},
                goods: [],
                remark: '',//备注
            };
        },
        onLoad(option) {
            if (option.data) {
                this.data = JSON.parse(decodeURIComponent(option.data));
                this.data.goods.forEach((item) => {
                	var obj = {
                		goods_id: item.goods_id,//商品id
                		goods_sku_id: item.goods_sku_id,//规格id
                        goods_nums: item.goods_nums,//商品数量
                        goods_name: item.goods_name,//商品名称
                	}
                	this.goods.push(obj)
                })
                console.log(this.data)
                
            }
            // 接收备注监听
            uni.$on('remarkZT', (data)=>{
            	this.remark = data;
            })
            
        },
        onShow() {
            // this.getAddress()
        },
        methods: {
            
            addOrder() {
                var that = this
                if (this.type == 1) {
                    if(!this.userAdd){
                    	this.$toast('请添加地址！')
                    	return
                    }
                } 
                // that.$confirm('下单成功，快去支付吧', function() {
                //     that.$pay(that.id, payType)
                // })
                this.$ajax('add_order', {
                    userToken: this.$getSync('userToken'),
                    franchisee_id: this.$getSync('franchiseeId'),//加盟商编号
                    order_type: this.data.data.order_type,//订单类型 1-商品订单 2-预约订单 3-积分订单 4-活动订单
                    goods: this.goods, //商品信息
                    balance: '',//使用余额金额
                    receiver_name: this.name,//收货人姓名
                    receiver_mobile: this.tel,//收货人电话
                    user_message: this.remark,//买家备注
                    receiver_sex: '',//收货人性别
                    user_address_id: this.type == 1 ? this.userAdd.id : '',//用户收货地址
                    shipping_type: this.type,//订单配送方式 0 自提 1配送
                    activity_id: '',//活动编号
                    store_id: this.type == 0 ? this.stores.id : 0,//店铺id，快递时传0
                }).then(ret => {
                	if (ret.status == 0) {
                        this.doPay(ret.data.id)
                	} else {
                		this.$toast(ret.message)
                	}
                })
            },
            doPay(id) {
                this.$ajax('pay', {
                	userToken: this.$getSync('userToken'),
                    franchisee_id: this.$getSync('franchiseeId'),//加盟商编号
                	id: id,
                    balance: 0,//使用余额金额 1使用 0没用
                }).then(ret => {
                	uni.hideLoading()
                	if (ret.status == 0) {
                        this.$toast('支付成功！');
                        setTimeout(() => {
                            uni.navigateBack({delta: 2})
                        }, 500)
                	} else {
                		this.$toast(ret.message);
                	}
                });
            },
            // 支付失败
            // payFail(id) {
            //     this.$ajax('fail', {
            //         userToken: this.$getSync('userToken'),
            //         id: id, //订单编号
            //     }).then(ret => {
            //     	if (ret.status == 0) {
                        
            //     	} else {
            //     		this.$toast(ret.message)
            //     	}
            //     })
            // },
            
            // 获取默认收货地址
            getAddress() {
                this.$ajax('userDefAddr', {
                    userToken: this.$getSync('userToken'),
                    franchisee_id: this.$getSync('franchiseeId'),//加盟商编号
                }).then(ret => {
                    if (ret.status == 0) {
                        this.userAdd = ret.data;
                    } else {
                        this.$toast(ret.message);
                    }
                });
            },
        }
    };
</script>

<style lang="scss">
    .freight{
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding-bottom: 25rpx;
		font-size: 26rpx;
	}
    
    
    page{
        background-color: #f5f5f5;
    }
    .content {
    	padding: 50rpx 20rpx 200rpx;
    }
    
    .bg {
    	width: 100%;
    	height: 390rpx;
    	position: absolute;
    	top: 0;
    	left: 0;
    	z-index: -1;
    	background: linear-gradient(to bottom, #2658aa, #f5f5f5);
    }
    .top{
        background-color: #fff;
        border-radius: 20rpx;
        margin-bottom: 20rpx;
    }
    .nav{
        display: flex;
        justify-content: space-between;
        align-items: center;
        position: relative;
    }
    .nav>view{
        width: calc(710rpx / 2);
        text-align: center;
        padding: 15rpx 0;
        font-size: 26rpx;
    }
    .nav-l{
        background-color: #f5ece1;
        border-radius: 20rpx 0 0 0 ;
    }
    .nav-r{
        background-color: #f5ece1;
        border-radius: 0 20rpx 0 0 ;
    }
    .active{
        background-color: #fff;
        font-size: 30rpx;
        font-weight: bold;
    }
    .active::after{
        display: block;
        content: '';
        width: calc(710rpx / 2);
        height: 40rpx;
        background-color: #fff;
        border-radius: 20rpx 20rpx 0 0;
        position: absolute;
        top: -20rpx;
        z-index: -1;
    }
    .unActiveL{
        border-radius: 20rpx 0 20rpx 0;
    }
    .unActiveR{
        border-radius: 0 20rpx 0 20rpx;
    }
    
    .down{
        padding: 40rpx 25rpx;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .add-text{
        padding-bottom: 10rpx;
    }
    .add-icon{
        vertical-align: middle;
        padding: 4rpx 12rpx;
        font-size: 18rpx;
        color: #fff;
        background-color: #f76d0a;
        border-radius: 6rpx;
        margin-right: 10rpx;
    }
    .add{
        vertical-align: middle;
        font-size: 36rpx;
        font-weight: bold;
    }
    .add-name{
        color: #8a8a8a;
        font-size: 28rpx;
        max-width: 380rpx;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .add-tel{
        color: #8a8a8a;
        font-size: 28rpx;
        padding-left: 30rpx;
    }
    .ziti{
        padding: 40rpx 25rpx;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .ziti-r{
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: flex-end;
    }
    .arrow-r-022{
        width: 12rpx;
        height: 20rpx;
    }
    .del-08{
        width: 123rpx;
        height: 123rpx;
        border: 2rpx solid #e6e6e6;
        border-radius: 5rpx;
        margin-top: 40rpx;
    }
    .ziti-tit{
        font-size: 26rpx;
        color: #8a8a8a;
        padding-bottom: 5rpx;
    }
    .ziti-name{
        max-width: 235rpx;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .write-icon{
        width: 20rpx;
        height: 21rpx;
        margin-left: 10rpx;
    }
    .border-r{
        border-right: 2rpx solid #e6e6e6;
    }
    
    
    .box{
        background-color: #fff;
        border-radius: 20rpx;
        margin-bottom: 20rpx;
        padding: 0 25rpx;
    }
    .item{
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 30rpx;
    }
    .del-07{
        width: 160rpx;
        height: 160rpx;
        border-radius: 10rpx;
        border: 2rpx solid #e6e6e6;
        margin-right: 15rpx;
    }
    .goods-name{
        font-size: 28rpx;
        font-weight: bold;
        width: 480rpx;
        // white-space: nowrap;
        // overflow: hidden;
        // text-overflow: ellipsis;
        // padding-bottom: 40rpx;
    }
    .price{
        // color: #f62a2a;
        font-size: 36rpx;
        font-weight: bold;
    }
    .point-icon{
        width: 18rpx;
        height: 18rpx;
        margin-right: 10rpx;
    }
    .total{
        padding-top: 30rpx;
        border-top: 2rpx solid #e6e6e6;
        display: flex;
        justify-content: flex-end;
        align-items: center;
    }
    .total-price{
        color: #f62a2a;
        font-size: 26rpx;
    }
    .total-price-num{
        color: #f62a2a;
        font-size: 42rpx;
        font-weight: bold;
    }
    
    .remark{
        width: 570rpx;
        text-align: right;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .arrow-r-02{
        width: 12rpx;
        height: 20rpx;
        margin-left: 10rpx;
    }
    
    .footer{
        width: 100vw;
        position: fixed;
        bottom: 0;
        left: 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 15rpx 20rpx;
        background-color: #fff;
    }
    .footer-price-num{
        // color: #f62a2a;
        font-size: 42rpx;
        font-weight: bold;
    }
    .footer-btn{
        font-size: 30rpx;
        color: #fff;
        padding: 15rpx 35rpx;
        background-color: #2658aa;
        border-radius: 50rpx;
    }
    
    // 自提人弹窗
    .privacy-pop {
        display: flex;
        align-items: center;
        justify-content: center;
        height: 100%;
    }
    .privacy-pop-box {
        width: 700rpx;
        padding: 40rpx 20rpx 20rpx;
        background-color: #fff;
        box-sizing: border-box;
        border-radius: 20rpx;
        position: relative;
    }
    .close-01{
        width: 40rpx;
        height: 40rpx;
        position: absolute;
        right: 20rpx;
        top: 20rpx;
    }
    .privacy-title {
        font-size: 32rpx;
        font-weight: bold;
        text-align: center;
        padding: 20rpx 0 40rpx;
    }
    .privacy-txt {
        font-size: 26rpx;
    }
    .privacy-item{
        height: 77rpx;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0 25rpx;
        margin-bottom: 20rpx;
    }
    .privacy-inp{
        width: 63vw;
        height: 77rpx;
        background-color: #f8f8f8;
        border-radius: 15rpx;
        line-height: 77rpx;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        padding-left: 20rpx;
    }
    .btn-text2{
        font-size: 30rpx;
        color: #fff;
        background-color: #b00c0f;
        padding: 20rpx 50rpx;
        border-radius: 50rpx;
        margin: 20rpx;
        text-align: center;
    }

</style>
